package com.sunseen.intelligencebus.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding

abstract class AbsBindingFragment : SupportFragment() {

    @LayoutRes
    abstract fun setLayout(): Int

    abstract fun onBindView(viewDataBinding: ViewDataBinding,bundle:Bundle?)

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val viewDataBinding = DataBindingUtil.inflate<ViewDataBinding>(inflater, setLayout(), container, false)
        onBindView(viewDataBinding,savedInstanceState)
        return viewDataBinding.root
    }

    fun <T : AbsBindingFragment> getParentDelegate(): T {
        return parentFragment as T
    }
}